<template>
  <h2>当前求和为: {{ sum }}</h2>
  <button @click="sum++">点我加1</button>
  <hr>
  <h2>当前点击时鼠标的坐标为: x:{{ point.x }} y:{{ point.y }}</h2>
</template>

<script>
// import { ref, reactive, onMounted, onBeforeUnmount } from "vue"; // ref处理基本类型数据  reactive处理引用类型数据
import { ref } from "vue"; // ref处理基本类型数据  reactive处理引用类型数据
import usePoint from '../hooks/usePoint'
export default {
  name: "demo",
  setup() {
    console.log('---setup---')
    let sum = ref(0);
    let point = usePoint()
    console.log(point)
    // let point = reactive({
    //   x: 0,
    //   y: 0
    // })

    // function savePoint(event){
    //   console.log(event.pageX,event.pageY)
    //   point.x= event.pageX
    //   point.y= event.pageY
    // }

    // onMounted(()=> {
    //   window.addEventListener('click', savePoint)
    // })

    // onBeforeUnmount(()=> {
    //   window.removeEventListener('click', savePoint)
    // })

    return {
      sum,
      point
    };
  },
};
</script>


